import * as actionType from './constants'

import {getDetailData} from '../../../api/index'
import { Toast } from 'antd-mobile'

export const changeDetail = (data) => {
    return {
        type: actionType.CHANGE_DETAIL_DATA,
        data
    }
}

export const requestDetailData = (id) => {
    // Toast.show({
    //     icon: 'loading',
    //     content: '加载中…',
    //     duration:0
    //   })
    return (dispatch) => {
        getDetailData(id)
            .then(data => {
                // console.log('这是详情页请求的数据',data.data.data);
                dispatch(changeDetail(data.data.data))
                Toast.clear()
            })
            .catch(error => {
                console.log('出错了');
                Toast.clear()
            })
    }
}